package com.max.project.graphics.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.max.common.proxy.ServiceProxyFactory;
import com.max.common.util.DataPage;
import com.max.project.graphics.dao.ContentDao;
import com.max.project.graphics.model.Content;
import com.max.project.graphics.service.ContentService;

/**
 * 
 * 项目名称:max-project-graphics
 * 文件名称:ContentServiceImpl.java
 * 文件描述:
 * 创建人员:chenyibo
 * 创建时间:2013-1-22 下午03:05:36
 * 修改人员:chenyibo
 * 修改时间:2013-1-22 下午03:05:36
 * 修改备注:
 * @version V1.0
 */
public class ContentServiceImpl implements ContentService
{

	private static ContentDao contentDao = new ServiceProxyFactory().create(ContentDao.class);
	
	
	@Override
	public int insert(Content content) throws SQLException 
	{
		return contentDao.insert(content);
	}

	@Override
	public Content query(int id) throws SQLException 
	{
		return contentDao.query(id);
	}

	@Override
	public DataPage<Content> query(int pageNo, int pageSize) throws SQLException 
	{
		DataPage<Content> dp = null;
		
		int total = contentDao.count();
		List<Content> list = contentDao.query((pageNo-1)*pageSize, pageSize);
		dp = new DataPage<Content>(list , pageNo, pageSize, total);
		
		return dp;
	}
}
